<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 对数组 arr = [1,2,3,3,5,3,2,4,8,19,10];进行去重;
        let arr = [1, 2, 3, 3, 5, 3, 2, 4, 8, 19, 10];
        let arr1 = [];
        for (let i = 0; i < arr.length; i++) {
            console.log(arr[i]);// 依次拿到数据

            let flag = false;//默认不存在

            for (let item of arr1) { //判断数组
                if (arr[i] == item) {
                    console.log('该元素已存在');
                    flag = true;
                }

            }
            //新数组不存在  则添加到空数组
            if (!flag) {
                arr1[arr1.length] = arr[i];
            }
        }
        console.log(arr1);
    </script>
</body>

</html>